package com.lovo.sheyingback.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lovo.sheyingback.bean.Function;
import com.lovo.sheyingback.service.FunctionService;
import com.lovo.sheyingback.dao.FunctionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* @author BDK-THINKPAD
* @description 针对表【t_function(功能表)】的数据库操作Service实现
* @createDate 2023-07-24 21:39:14
*/
@Service
public class FunctionServiceImpl implements FunctionService{
    @Autowired
    private FunctionMapper functionMapper;
    @Override
    public PageInfo<Function> listFunction(Integer current, Integer pageSize) {
        PageHelper.startPage(current,pageSize);
        List<Function> functions = functionMapper.listFunction();
        return new PageInfo<>(functions);
    }

    @Override
    public Function getById(Integer id) {
        return functionMapper.getById(id);
    }

    @Override
    public int insert(Function function) {
        return functionMapper.insert(function);
    }

    @Override
    public int update(Function function) {
        return functionMapper.update(function);
    }

    @Override
    @Transactional
    public int delete(Integer id) {
        functionMapper.deleteFunctionUser(id);
        functionMapper.deleteFunctionRole(id);
        return functionMapper.delete(id);
    }
}




